#include "qtreewidgetex.h"

QTreeWidgetEx::QTreeWidgetEx(QWidget *parent) :
    QTreeWidget(parent)
{
}

QTreeWidgetItem *QTreeWidgetEx::get_item(const QList<int> &indexs)
{
    QTreeWidgetItem *item=NULL;

    if(indexs.size()==0)
    {
        return NULL;
    }
    int pt=indexs.first();

    if(pt<0 || pt>=topLevelItemCount())
    {
        return NULL;
    }

    item=topLevelItem(pt);

    for(int i=1;i<indexs.size();i++)
    {
        pt=indexs.at(i);
        if(pt<0 || pt>=item->childCount())
        {
            return item;
        }
        else
        {
            item=item->child(pt);
        }
    }

    return item;
}
